//
//  LHRecommendHomePageCollectionViewCell.m
//  Knight_Tour
//
//  Created by 庞魁 on 15-5-21.
//  Copyright (c) 2015年 TouchOne. All rights reserved.
//

#import "LHRecommendHomePageCollectionViewCell.h"
#import "UIImageView+WebCache.h"

@interface LHRecommendHomePageCollectionViewCell ()

@property (nonatomic, retain) UIImageView *notesPic;
@property (nonatomic, retain) UILabel *notesCountry;
@property (nonatomic, retain) UILabel *notesTheme;


@end

@implementation LHRecommendHomePageCollectionViewCell


- (void)dealloc
{
    [_notesPic release];
    [_notesCountry release];
    [_notesTheme release];
    [_notesModel release];
    [super dealloc];
    
}

/**
 *  重写初始化
 */

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    
    if (self) {
        
        
        // 相框创建
        self.notesPic = [[UIImageView alloc] init];
        
        [self.contentView addSubview:_notesPic];
        
        self.notesPic.layer.cornerRadius = 5;
        self.notesPic.clipsToBounds = YES;
        
        [_notesPic release];
        
        // 游记地点创建
        self.notesCountry = [[UILabel alloc] init];
        
//        _notesCountry.backgroundColor = [UIColor colorWithRed:0.857 green:0.964 blue:0.917 alpha:0.2];
        
        [_notesCountry setFont:[UIFont fontWithName:@"Helvetica-Bold" size:13]];
        
        [_notesCountry setTextColor:[UIColor whiteColor]];
        
        [_notesCountry setShadowColor:[UIColor blackColor]];
        
        [_notesCountry setShadowOffset:CGSizeMake(1, 0)];
        
        [_notesPic addSubview:_notesCountry];
        
        [_notesCountry release];

        
        // 游记主题创建
        self.notesTheme = [[UILabel alloc] init];
        
        [_notesTheme setFont:[UIFont fontWithName:@"Helvetica-Bold" size:11]];
        
        [_notesTheme setTextColor:[UIColor whiteColor]];
        
        [_notesTheme setShadowColor:[UIColor blackColor]];
        
        [_notesTheme setShadowOffset:CGSizeMake(1, 0)];
        
        [_notesPic addSubview:_notesTheme];
        
        [_notesTheme release];
        
    }
    
    
    return self;
}

// 设置空间布局新信息
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    _notesPic.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.width);
    
    _notesCountry.frame = CGRectMake(10, _notesPic.frame.size.height - 60, 160, 20);
    
    _notesTheme.frame = CGRectMake(10, _notesPic.frame.size.height - 30, 160, 20);
    
}

// 重写setter方法
- (void)setNotesModel:(LHRecommendTravelNotesModel *)notesModel
{
    if (_notesModel != notesModel) {
        
        [_notesModel release];
        
        _notesModel = [notesModel retain];
        
    }
    
    [_notesPic sd_setImageWithURL:[NSURL URLWithString:notesModel.cover_image_w640] placeholderImage:[UIImage imageNamed:@"word4"]];
    
    _notesCountry.text = notesModel.popular_place_str;
    
    _notesTheme.text = notesModel.name;
}












@end
